import request from "@/utils/request";

// 查询优惠劵列表
export function creationList(query) {
  return request({
    url: "/coupon/creation/list",
    method: "get",
    params: query,
  });
}

// 删除优惠劵
// POST /coupon/creation/delete
export function creationDelete(ids) {
  return request({
    url: "/coupon/creation/delete",
    method: "post",
    data: ids,
  });
}
/**
 * Coupon Creation Controller
 * 优惠券创建控制器
 */

// 创建优惠劵
// POST /coupon/creation/creation
export function createCoupon(data) {
  return request({
    url: "/coupon/creation/creation",
    method: "post",
    data,
  });
}

// 优惠券详情
// GET /coupon/creation/details/{id}
export function getCouponDetails(id) {
  return request({
    url: `/coupon/creation/details/${id}`,
    method: "get",
  });
}

// 优惠券复制模板
// GET /coupon/creation/getInfoForCopy/{id}
export function getCouponCopyTemplate(id) {
  return request({
    url: `/coupon/creation/getInfoForCopy/${id}`,
    method: "get",
  });
}

// 修改优惠劵
// PUT /coupon/creation/modify
export function modifyCoupon(data) {
  return request({
    url: "/coupon/creation/modify",
    method: "put",
    data,
  });
}

// 更新优惠券状态
// PUT /coupon/creation/status/{issueId}
export function updateCouponStatus(issueId, status) {
  return request({
    url: `/coupon/creation/status/${issueId}`,
    method: "put",
    params: {
      status: status,
    },
  });
}

// 作废优惠卷
export function cancelTheCoupon(id) {
  return request({
    url: `/coupon/user/delete/${id}`,
    method: "get",
  });
}

// 批量作废优惠卷
export function batchVoid(ids) {
  return request({
    url: "/coupon/user/batchDelete",
    method: "post",
    data: ids,
  });
}
